package com.trkj.dao.jpa;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.CcHospapply;

public interface CcHospapplyDAO extends CrudRepository<CcHospapply,Long> {
	@Query("select new CcHospapply(ccHosp.applyid, ccHosp.adate, ccHosp.haname, ccHosp.hdoctorid, ccHosp.hmedicalid,"
			+ "ccHosp.hpdate, ccHosp.hpdoctorid, ccHosp.hpofficeid, ccHosp.hpremarks,ccHosp.hpsex) from CcHospapply ccHosp where ccHosp.hpremarks='未完成' order by ccHosp.adate desc")
	public List<CcHospapply> findByHpremarks(Pageable pageable);
	@Query("select new CcHospapply(ccHosp.applyid, ccHosp.adate, ccHosp.haname, ccHosp.hdoctorid, ccHosp.hmedicalid,"
			+ "ccHosp.hpdate, ccHosp.hpdoctorid, ccHosp.hpofficeid, ccHosp.hpremarks,ccHosp.hpsex) from CcHospapply ccHosp  order by ccHosp.adate desc")
	public List<CcHospapply> findByAll(Pageable pageable);
	@Query("select count(*) from CcHospapply ccHosp where ccHosp.hpremarks='未完成'")
	public long findBycount();
	@Query("select new CcHospapply(ccHosp.applyid, ccHosp.adate, ccHosp.haname, ccHosp.hdoctorid, ccHosp.hmedicalid,"
			+ "ccHosp.hpdate, ccHosp.hpdoctorid, ccHosp.hpofficeid, ccHosp.hpremarks,ccHosp.hpsex) from CcHospapply ccHosp where ccHosp.haname like %?1% order by ccHosp.adate desc")
	public List<CcHospapply> findByHaname(Pageable pageable,String haname);
	
	@Query("select count(*) from CcHospapply ccHosp where ccHosp.haname like %?1% ")
	public long findByHanamecount(String haname);
	@Query("select count(*) from CcHospapply ccHosp where ccHosp.hmedicalid=?1")
	public long findByHmedicalidcount(BigDecimal hmedicalid);
	@Query("select new CcHospapply(ccHosp.applyid, ccHosp.adate, ccHosp.haname, ccHosp.hdoctorid, ccHosp.hmedicalid,"
			+ "ccHosp.hpdate, ccHosp.hpdoctorid, ccHosp.hpofficeid, ccHosp.hpremarks,ccHosp.hpsex) from CcHospapply ccHosp where ccHosp.hmedicalid=?1 order by ccHosp.adate desc")
	public List<CcHospapply> findByHmedicalid(Pageable pageable,BigDecimal hmedicalid);
	
}
